package com.stusy.blog.everythingblogweb.util;

import lombok.extern.slf4j.Slf4j;

/**
 * @author Xinpei Li
 * @create 2022-02-21 10:54
 */

@Slf4j
public class BaseUtils {


    public final static String encrypt(String password) {
        try {

            return Encrypt.encryptBASE64(password.getBytes());
        } catch (Exception e) {
            log.error("encrypt error", e);
        }
        return null;
    }

    public final static String deCrypt(String code){
        try {
            return new String(Encrypt.decryptBASE64(code));

        } catch (Exception e) {
            log.error("decrypt error", e);
        }
        return null;
    }

    public static void main(String[] args) {
        String sid = System.currentTimeMillis() + "|" + "kite" + "|" + "everything-blog";
        System.out.println("sid = "+sid);
        String encrypt = encrypt(sid);
        System.out.println("encrypt= "+ encrypt);
        System.out.println("==============================");
        String s = deCrypt(encrypt);
        System.out.println("decrypt= "+s);

    }



}
